//package com.zhu.tool_test.starke.config;
//
//
//import com.zhu.tool_test.starke.framework.redis.EventProcesser;
//import com.zhu.tool_test.starke.framework.redis.controller.EventController;
//import com.zhu.tool_test.starke.util.weapons.EntityWeapons;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.redis.connection.RedisConnectionFactory;
//import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
//import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
//import org.springframework.data.redis.core.RedisTemplate;
//
///**
// * @author 4everlynn
// * @version V1.0
// * @description
// * @date 2019-07-03
// */
//@Configuration
//public class EventQueueConfig {
//    @Autowired
//    private StarkeProperties properties;
//
//
//    @Bean
//    @ConditionalOnMissingBean(EventController.class)
//    public EventController eventController() {
//        EventController controller = new EventController();
//        // config for rpcTimeout
//        controller.setRpcTimeout(properties.getRpcTimeout());
//        return controller;
//    }
//
//    @Bean("starke-redis-tmpl")
//    @ConditionalOnMissingBean(RedisTemplate.class)
//    public RedisTemplate<Object, Object> redisTemplate() {
//        RedisTemplate<Object, Object> template = new RedisTemplate<>();
//        template.setConnectionFactory(redisConnectionFactory());
//        return template;
//    }
//
//    @Bean
//    @ConditionalOnMissingBean(EventProcesser.class)
//    public EventProcesser eventProcesser() {
//        return new EventProcesser();
//    }
//
//
//    @Bean
//    public RedisConnectionFactory redisConnectionFactory() {
//        RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration();
//        configuration.setHostName(properties.getRedisHost());
//        configuration.setPort(properties.getRedisPort());
//        configuration.setPassword(properties.getRedisPassword());
//        return new JedisConnectionFactory(configuration);
//    }
//
//
//    @Bean("starke-string-redis-tmpl")
//    public RedisTemplate<String, Object> stringObjectRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
//        RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
//        // 设置redis连接
//        redisTemplate.setConnectionFactory(redisConnectionFactory);
//        // HashValue
//        EntityWeapons
//                .instance(properties.getRedisHashValueSerializer())
//                .ifPresent(redisTemplate::setHashValueSerializer);
//        // HashKey
//        EntityWeapons
//                .instance(properties.getRedisHashKeySerializer())
//                .ifPresent(redisTemplate::setHashKeySerializer);
//        // Value
//        EntityWeapons
//                .instance(properties.getRedisValueSerializer())
//                .ifPresent(redisTemplate::setValueSerializer);
//        // Key
//        EntityWeapons
//                .instance(properties.getRedisKeySerializer())
//                .ifPresent(redisTemplate::setKeySerializer);
//        redisTemplate.afterPropertiesSet();
//        return redisTemplate;
//    }
//}
